/*
 * Class of Shadow Memory
 *
 * Author: Zhang Yichao
 * Date: 2010-4-20
 *
 * 		G-Crossbit Group
 */

#ifndef SHADOWPAGE_H
#define SHADOWPAGE_H

#include "common.h"
#include <vector>

namespace crossbit{

#define PAGE_INDEX(addr) (addr>>12)
#define PAGE_ALIGN(addr) (addr&~0xFFF)
#define PAGE_OFFSET(addr) (addr&0xFFF)

#define PAGE_SIZE	1024*4

#define PAGE_NUM	1024*1024

	class ShadowPage;

	class PageData
	{
		friend class ShadowPage;

		private:
		XTUint8 mem_data[PAGE_SIZE];
	};

	class ShadowPage
	{
		public:
			ShadowPage();

			void writeMem( XTMemAddr addr, XTInt32 size, XTUint32 value );

			void readMem( XTMemAddr addr, XTInt32 size ); 

			void dumpMemData( XTFile fd );
			void loadMemData( XTFile fd );

		private:
			PageData** page_table;

	};

}
#endif
